
import { reqCategoryList, reqFloorList, reqGetBannerList } from "@/api";
export default {
  state: {
    categoryList: [],
    bannerList: [],
    floorList:[]
  },   //仓库储存的地方
  mutations: {
    CATEGORYLIST(state, categoryList) {
      state.categoryList = categoryList;
    },
    BANNERLIST(state, bannerList) {
      state.bannerList = bannerList;
    },
    GETFLOORLIST(state, floorlist) {
      state.floorList = floorlist;
    }
  },    //修改数据的地方
  actions: {
    async categoryList({ commit }) {
      let res = await reqCategoryList();
      if (res.code === 200) {
        commit("CATEGORYLIST", res.data)
      }
    },
    async getBannerList({ commit }) {
      try {
        const res = await reqGetBannerList();
        if (res.code === 200) {
          commit("BANNERLIST", res.data);
        }
      } catch (error) {
        console.error("Error while fetching banners list:", error);
      }
    },
    async getFloorList({ commit }) {
      let res = await reqFloorList();
      if(res.code==200){
        commit("GETFLOORLIST",res.data)
      }
    }
  },  //处理action
  getters: {}  //类似于计算属性
}